<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DentalGUIHelper;assembly=DentalConfig">
    <ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="..\Brushes\Common.xaml"/>
		<ResourceDictionary Source="..\NamedStyles\NamedButtonStyles.xaml "/>
    </ResourceDictionary.MergedDictionaries>

  <!-- ========================= -->
  <!--        Converters         -->
  <!-- ========================= -->
  <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
  <Style x:Key="IronicallyNamedChromelessButtonStyleForWindowCommand" TargetType="{x:Type Button}" BasedOn="{StaticResource IronicallyNamedChromelessButtonStyle}">
      <Style.Resources>
               <!-- we need staticrecource here for whatever reasons -->
  		<SolidColorBrush x:Key="IronicallyNamedChromelessButtonPressedBackgroundBrush" Color="{StaticResource WindowCommandsButtonPressedBackgroundColor}"/>
      </Style.Resources>
  </Style>

  <!-- ========================= -->
  <!--   WindowsCommands Style   -->
  <!-- ========================= -->
  <Style TargetType="{x:Type local:WindowCommands}">
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Foreground" Value="{DynamicResource WindowCommandButtonBrush}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="local:WindowCommands">

          <StackPanel Orientation="Horizontal" VerticalAlignment="Top" >
            <ItemsControl IsTabStop="False" ItemsSource="{Binding Items, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}}">
              <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                  <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
              </ItemsControl.ItemsPanel>
            </ItemsControl>
            <Button x:Name="PART_Min"
                IsTabStop="False"
                Width="34"
                Height="34"
                MaxHeight="34"
                Style="{DynamicResource IronicallyNamedChromelessButtonStyleForWindowCommand}"
                Padding="0"
                Tag="{Binding ., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}}"
                Visibility="{Binding ShowMinButton, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}, Converter={StaticResource BooleanToVisibilityConverter}}">
              <Path Data="F1M0,6L0,9 9,9 9,6 0,6z" SnapsToDevicePixels="True"  Fill="{TemplateBinding Foreground}"/>
              <Button.ToolTip >
                <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
                  <TextBlock Text="{Binding Tag.Minimize}"/>
                </ToolTip>
              </Button.ToolTip>
            </Button>

            <Button x:Name="PART_Max"
                IsTabStop="False"
                Width="34"
                Height="34"
                MaxHeight="34"
                Style="{DynamicResource IronicallyNamedChromelessButtonStyleForWindowCommand}"
                Padding="0"
                Tag="{Binding ., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}}"
    
                Foreground="{TemplateBinding Foreground}"
                Visibility="{Binding ShowMaxRestoreButton, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}, Converter={StaticResource BooleanToVisibilityConverter}}">
              <Grid>
                <Path x:Name="MaximisePath" SnapsToDevicePixels="True" Data="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z" Fill="{TemplateBinding Foreground}"/>
                <Path x:Name="RestorePath" SnapsToDevicePixels="True" Data="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z"  Fill="{TemplateBinding Foreground}"/>
              </Grid>
              <Button.ToolTip >
                <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
                  <TextBlock Text="{Binding Tag.Maximize}"/>
                </ToolTip>
              </Button.ToolTip>
            </Button>

            <Button x:Name="PART_Close"
                IsTabStop="False"
                Width="34"
                Height="34"
                MaxHeight="34"
                Tag="{Binding ., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}}"
                
                Style="{DynamicResource IronicallyNamedChromelessButtonStyleForWindowCommand}"
                Visibility="{Binding ShowCloseButton, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WindowCommands}}, Converter={StaticResource BooleanToVisibilityConverter}}"
                Foreground="{TemplateBinding Foreground}">
              <Path Data="F1M0,0L2,0 5,3 8,0 10,0 6,4 10,8 8,8 5,5 2,8 0,8 4,4 0,0z"  SnapsToDevicePixels="True"  Fill="{TemplateBinding Foreground}"/>
              <Button.ToolTip >
                <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
                    <TextBlock Text="{Binding Tag.Close}"/>
                </ToolTip>
              </Button.ToolTip>

            </Button>
          </StackPanel>

        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>